package com.yj.provider.controller;

import com.yj.provider.exception.BusinessException;
import com.yj.provider.service.TestService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.cloud.context.config.annotation.RefreshScope;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RefreshScope
public class TestController {


    @Value("${environment}")
    private String environment;

    @Autowired
    TestService testService;

    @GetMapping("env")
    public String env(){

        try {
            int i = 1/0;
        } catch (Exception e) {
            throw new BusinessException("除数不能为0");
        }

        return environment;
    }

    @GetMapping("do")
    public String test(){
        String test = testService.test();
        return test;
    }

}
